if require("sknvim.config").ide_mode then
    local function setup_cmp()
        local cmp = require("cmp")

        cmp.setup({
            snippet = {
                expand = function(args)
                    require("luasnip").lsp_expand(args.body)
                end,
            },
            window = {
                completion = {
                    winhighlight = "Normal:Pmenu,FloatBorder:Pmenu,Search:None",
                },
            },
            mapping = cmp.mapping.preset.insert({
                ["<C-b>"] = cmp.mapping.scroll_docs(-4),
                ["<C-f>"] = cmp.mapping.scroll_docs(4),
                ["<C-e>"] = cmp.mapping.abort(),
                ["<CR>"] = cmp.mapping.confirm({ select = true }),
            }),
            sources = cmp.config.sources({
                { name = "nvim_lsp" },
                { name = "luasnip" },
                { name = "path" },
            }, {
                { name = "buffer" },
            }),
        })

        cmp.setup.cmdline(':', {
            mapping = cmp.mapping.preset.cmdline(),
            sources = cmp.config.sources({
                { name = "path" }
            }, {
                { name = "cmdline" }
            }),
            matching = { disallow_symbol_nonprefix_matching = false }
        })
    end

    local function setup_lspconfig()
        local capabilities = require("cmp_nvim_lsp").default_capabilities()
        local function setup_lang_server(name)
            require("lspconfig")[name].setup({ capabilities = capabilities })
        end

        local langservers = {
            "clangd",
            "lua_ls",
            "jedi_language_server",
            "html",
            "cssls",
            "bashls",
            "zls",
            -- "rust_analyzer",
        }
        if require("sknvim.config").javafag then
            table.insert(langservers, "jdtls")
            table.insert(langservers, "kotlin_language_server")
        end
        for _, i in pairs(langservers) do
            setup_lang_server(i)
        end
        -- setup_lang_server('ltex')
    end

    return {
        url = "https://github.com/hrsh7th/nvim-cmp",
        keys = {
            { "<leader>fd", vim.diagnostic.open_float },
        },
        lazy = false,
        dependencies = {
            "https://github.com/neovim/nvim-lspconfig",
            "https://github.com/hrsh7th/cmp-nvim-lsp",
            "https://github.com/hrsh7th/cmp-buffer",
            "https://github.com/hrsh7th/cmp-path",
            "https://github.com/hrsh7th/cmp-cmdline",
            "https://github.com/L3MON4D3/LuaSnip",
            "https://github.com/saadparwaiz1/cmp_luasnip",
        },
        config = function()
            setup_cmp()
            setup_lspconfig()
        end,
    }
end

return {}
